package com.sfzy.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sfzy.entity.ClassQaAnswer;
import com.sfzy.entity.ClassQaQuestion;
import com.sfzy.mapper.ClassQaAnswerMapper;
import com.sfzy.service.ClassQaAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassQaAnswerServiceImpl implements ClassQaAnswerService {
    @Autowired
    private ClassQaAnswerMapper classQaAnswerMapper;

    @Override
    public int addClassQaAnswer(ClassQaAnswer classQaAnswer) {
        return classQaAnswerMapper.addClassQaAnswer(classQaAnswer);
    }

    @Override
    public int deleteClassQaAnswer(int id) {
        return classQaAnswerMapper.deleteClassQaAnswer(id);
    }

    @Override
    public int updateClassQaAnswer(ClassQaAnswer classQaAnswer) {
        return classQaAnswerMapper.updateClassQaAnswer(classQaAnswer);
    }

    @Override
    public ClassQaAnswer getById(int id) {
        return classQaAnswerMapper.getById(id);
    }

    @Override
    public PageInfo<ClassQaAnswer> getByPage(ClassQaAnswer classQaAnswer, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ClassQaAnswer> classQaAnswers = classQaAnswerMapper.getByPage(classQaAnswer);
        PageInfo<ClassQaAnswer> pageInfo = new PageInfo<>(classQaAnswers);
        return pageInfo;
    }
    }

